//
//  SearchForDiseaseListIPhoneCell.m
//  RoadMaintain
//
//  Created by 岳学坤 on 2017/3/7.
//  Copyright © 2017年 岳学坤. All rights reserved.
//

#import "SearchForDiseaseListIPhoneCell.h"

@implementation SearchForDiseaseListIPhoneCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setUI];
    }
    return self;
}
- (void)setUI{
    
    self.img = [[UIImageView alloc]init];
    self.img.contentMode = UIViewContentModeScaleAspectFill;
    self.img.clipsToBounds = YES;
    self.img.image = [UIImage imageNamed:@"road"];
    [self.contentView addSubview:self.img];
    [self.img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(15*WidthRate);
        make.width.mas_equalTo(90*WidthRate);
        make.height.mas_equalTo(70*WidthRate);
    }];
    
    self.firstLab = [[UILabel alloc]init];
    self.firstLab.textColor = Black_Color;
    self.firstLab.numberOfLines = 0;
    self.firstLab.text = @"XCG76K100K30010203040001";
    self.firstLab.font = [UIFont systemFontOfSize:13*ZitiRate];
    [self.contentView addSubview:self.firstLab];
   
    
    self.secondLab = [[UILabel alloc]init];
    self.secondLab.textColor = Gray_Color;
    self.secondLab.text = @"巡检时间：2017-01-04 15：30";
    self.secondLab.font = [UIFont systemFontOfSize:13*ZitiRate];
    [self.contentView addSubview:self.secondLab];
    
    
    self.thirdLab = [[UILabel alloc]init];
    self.thirdLab.textColor = Gray_Color;
    self.thirdLab.text = @"没有东西";
    self.thirdLab.font = [UIFont systemFontOfSize:13*ZitiRate];
    [self.contentView addSubview:self.thirdLab];
    
    
    self.fourthLab = [[UILabel alloc]init];
    self.fourthLab.textColor = Gray_Color;
    self.fourthLab.hidden = YES;
    self.fourthLab.font = [UIFont systemFontOfSize:13*ZitiRate];
    [self.contentView addSubview:self.fourthLab];
  
    
    self.fiveLab = [[UILabel alloc]init];
    self.fiveLab.textColor = Gray_Color;
    self.fiveLab.font = [UIFont systemFontOfSize:13*ZitiRate];
    [self.contentView addSubview:self.fiveLab];
   
    
    self.sixLab = [[UILabel alloc]init];
    self.sixLab.textColor = Gray_Color;
    self.sixLab.text = @"状态：待提交";
    self.sixLab.textAlignment = 2;
    self.sixLab.font = [UIFont systemFontOfSize:13*ZitiRate];
    [self.contentView addSubview:self.sixLab];
    
    
    self.line = [[UIView alloc]init];
    self.line.backgroundColor = Line_Color;
    [self.contentView addSubview:self.line];
   
}
//病害巡查
- (void)searchForDiseaseAddValue:(NSDictionary *)dic{
    [self.img sd_setImageWithURL:[NSURL URLWithString:dic[@"filePath"]] placeholderImage:[UIImage imageNamed:@"road"]];
    self.firstLab.text = dic[@"billNo"];
    
    self.secondLab.text = [NSString stringWithFormat:@"巡检时间：%@",dic[@"inspectionDate"]];
    self.thirdLab.hidden = YES;
    self.fourthLab.hidden = YES;
    self.fiveLab.text   = [NSString stringWithFormat:@"巡查人：%@",dic[@"inspectionUserName"]];
    NSString *str =[NSString stringWithFormat:@"%@", dic[@"vcBooleanCode"]];
    if ([str integerValue]) {
        self.sixLab.text = @"状态：已上报";
    }else{
        self.sixLab.text = @"状态：未上报";
    }
    CGSize size = [self.firstLab sizeThatFits:CGSizeMake(240*WidthRate, MAXFLOAT)];
    [self updateMas:size];
    }
- (void)updateMas:(CGSize)size{
    [self.firstLab mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(15*WidthRate);
        make.left.mas_equalTo(120*WidthRate);
        make.right.mas_equalTo(-15*WidthRate);
        make.height.mas_equalTo(size.height);
    }];
    
    [self.secondLab mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.firstLab.mas_bottom).offset(10*WidthRate);
        make.left.mas_equalTo(120*WidthRate);
        make.right.mas_equalTo(-15*WidthRate);
        make.height.mas_equalTo(13*WidthRate);
    }];
    
    [self.thirdLab mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.secondLab.mas_bottom).offset(5*WidthRate);
        make.left.mas_equalTo(120*WidthRate);
        make.right.mas_equalTo(-15*WidthRate);
        make.height.mas_equalTo(13*WidthRate);
    }];
    [self.fourthLab mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.thirdLab.mas_bottom).offset(5*WidthRate);
        make.left.mas_equalTo(120*WidthRate);
        make.right.mas_equalTo(-15*WidthRate);
        make.height.mas_equalTo(13*WidthRate);
    }];
    [self.fiveLab mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.thirdLab.mas_bottom).offset(5*WidthRate);
        make.left.mas_equalTo(120*WidthRate);
        make.width.mas_equalTo(110*WidthRate);
        make.height.mas_equalTo(13*WidthRate);
    }];
    
    [self.sixLab mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.thirdLab.mas_bottom).offset(5*WidthRate);
        make.left.mas_equalTo(230*WidthRate);
        make.width.mas_equalTo(130*WidthRate);
        make.height.mas_equalTo(13*WidthRate);
    }];
    [self.line mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(1);
    }];
    self.cellHeight = 87*WidthRate+size.height;
}
//维修通知
- (void)mainTainNotificationAddValue:(NSDictionary *)dic{
    [self.img sd_setImageWithURL:[NSURL URLWithString:dic[@"filePath"]] placeholderImage:[UIImage imageNamed:@"road"]];
    self.firstLab.text = dic[@"billNo"];
    CGSize size = [self.firstLab sizeThatFits:CGSizeMake(240*WidthRate, MAXFLOAT)];
    NSString *str =[NSString stringWithFormat:@"%@", dic[@"state"]];
    if ([str integerValue]== 3) {
        self.secondLab.text = @"状态：已做验收合格";
    }else if ([str integerValue]== 2) {
        self.secondLab.text = @"状态：已做验收未合格";
    }else if ([str integerValue]== 1) {
        self.secondLab.text = @"状态：已制作维修日志";
    }else{
        self.secondLab.text = @"状态：未制作维修日志";
    }
    self.thirdLab.hidden = YES;
    self.fourthLab.hidden = NO;
    self.fourthLab.text = [NSString stringWithFormat:@"日期：%@—%@",dic[@"startDate"],dic[@"endDate"]];
    self.fiveLab.hidden = YES;
    self.sixLab.hidden = YES;
    [self updateMas:size];
}
//验收通知
- (void)acceptanceNotificationAddValue:(NSDictionary *)dic{
    [self.img sd_setImageWithURL:[NSURL URLWithString:dic[@"filePath"]] placeholderImage:[UIImage imageNamed:@"road"]];
    self.firstLab.text = dic[@"acceptanceNoticeNo"];
    CGSize size = [self.firstLab sizeThatFits:CGSizeMake(240*WidthRate, MAXFLOAT)];
    NSString *str =[NSString stringWithFormat:@"%@", dic[@"vcBooleanCode"]];
    if ([str integerValue]==2) {
        self.secondLab.text = @"状态：已制作验收日志";
    }else{
        self.secondLab.text = @"状态：未制作验收日志";
    }
    self.thirdLab.hidden = YES;
    self.fourthLab.hidden = NO;
    self.fourthLab.text = [NSString stringWithFormat:@"验收日期： %@",dic[@"acceptanceDate"]];
    self.fiveLab.hidden = YES;
    self.sixLab.hidden = YES;
    [self updateMas:size];
}
//病害维修
- (void)diseaseMaintainAddValue:(NSDictionary *)dic{
    [self.img sd_setImageWithURL:[NSURL URLWithString:dic[@"filePath"]] placeholderImage:[UIImage imageNamed:@"road"]];
    self.firstLab.text = dic[@"billNo"];
    CGSize size = [self.firstLab sizeThatFits:CGSizeMake(240*WidthRate, MAXFLOAT)];
    self.secondLab.text = [NSString stringWithFormat:@"维修时间：%@—%@",dic[@"startDate"],dic[@"endDate"]];
    self.thirdLab.hidden = YES;
    self.fourthLab.hidden = YES;
    self.fiveLab.text   = [NSString stringWithFormat:@"巡查人：%@",dic[@"inspectionUserName"]];
    NSString *str =[NSString stringWithFormat:@"%@", dic[@"vcBooleanCode"]];
    if ([str integerValue]==2) {
        self.sixLab.text = @"状态：已上报已登记";
    }else if ([str integerValue]==1){
        self.sixLab.text = @"状态：已上报未登记";
    }else{
        self.sixLab.text = @"状态：未上报";
    }
        [self updateMas:size];
}
//安全检查
- (void)safetyCheckAddValue:(NSDictionary *)dic{
    [self.img sd_setImageWithURL:[NSURL URLWithString:dic[@"filePath"]] placeholderImage:[UIImage imageNamed:@"road"]];
    self.firstLab.text = dic[@"billNo"];
    CGSize size = [self.firstLab sizeThatFits:CGSizeMake(240*WidthRate, MAXFLOAT)];
    self.secondLab.text = [NSString stringWithFormat:@"签发时间：%@",dic[@"signDate"]];
    self.thirdLab.hidden = YES;
    self.fourthLab.hidden = YES;
    self.fiveLab.text   = [NSString stringWithFormat:@"签发人：%@",dic[@"signerUserName"]];
    NSString *str =[NSString stringWithFormat:@"%@", dic[@"vcBooleanCode"]];
    if ([str integerValue]) {
        self.sixLab.text = @"状态：已上报";
    }else{
        self.sixLab.text = @"状态：未上报";
    }
        [self updateMas:size];
}
//病害验收
- (void)diseaseReceiveAddValue:(NSDictionary *)dic{
    [self.img sd_setImageWithURL:[NSURL URLWithString:dic[@"filePath"]] placeholderImage:[UIImage imageNamed:@"road"]];
    self.firstLab.text = dic[@"billNo"];
    CGSize size = [self.firstLab sizeThatFits:CGSizeMake(240*WidthRate, MAXFLOAT)];
    self.secondLab.text = [NSString stringWithFormat:@"验收发起部门：%@",dic[@"maintenanceDepartment"]];
    self.thirdLab.text = [NSString stringWithFormat:@"验收签字日期：%@",dic[@"accepteSignDate"]];
    self.fourthLab.hidden = NO;
    NSString *str =[NSString stringWithFormat:@"%@", dic[@"vcBooleanCode"]];
    if ([str integerValue]) {
        self.fourthLab.text = @"状态：已上报";
    }else{
        self.fourthLab.text = @"状态：未上报";
    }
    self.fiveLab.hidden = YES;
    self.sixLab.hidden = YES;
        [self updateMas:size];
}
@end
